#!/bin/bash

BUILD_TAG="1.0"
REGISTRY_URL="registry-internal.cn-hangzhou.aliyuncs.com"
NAME_SPACE="yangguoliang"

if [ "$2" != "" ];
    then
    BUILD_TAG="$2"
fi

# build_push_tag
push_tag()
{
    set -e
    # mall-member
    docker tag cloud-mall/mall-member:latest $REGISTRY_URL/$NAME_SPACE/mall-member:$BUILD_TAG
    docker push $REGISTRY_URL/$NAME_SPACE/mall-member:$BUILD_TAG
    docker rmi cloud-mall/mall-member:latest
    docker rmi $REGISTRY_URL/$NAME_SPACE/mall-member:$BUILD_TAG
}

if [ "$1" = "test" ];
    then
    # login
    REGISTRY_URL="registry.cn-hangzhou.aliyuncs.com"
    NAME_SPACE="yangguoliang"
    docker login --username=19951761632 $REGISTRY_URL --password=19931203ygl
    push_tag
    echo '测试环境参考命令:dpush.sh test 1.0'
elif [ "$1" = "prod" ];
    then
    REGISTRY_URL="registry-internal.cn-hangzhou.aliyuncs.com"
    NAME_SPACE="c-wms-publish"
    docker login --username=上海弘人 $REGISTRY_URL --password=cwms@1234
    push_tag
    else
    echo '测试环境参考命令:dpush.sh test test1001'
    echo '生产环境参考命令:dpush.sh prod prod1001'
fi
